<!doctype html>



  


<html class="theme-next mist use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="模块使用," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />






<meta name="description" content="requesets模块使用">
<meta property="og:type" content="article">
<meta property="og:title" content="python requests模块的使用">
<meta property="og:url" content="http://rainy008.github.io/2016/12/28/(转载) python requests模块的使用/index.html">
<meta property="og:site_name" content="Rainy008">
<meta property="og:description" content="requesets模块使用">
<meta property="og:updated_time" content="2016-12-28T12:56:16.435Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="python requests模块的使用">
<meta name="twitter:description" content="requesets模块使用">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>

  <title> python requests模块的使用 | Rainy008 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">Rainy008</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">重拾梦想  茕茕前行</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                python requests模块的使用
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-12-28T20:54:43+08:00" content="2016-12-28">
              2016-12-28
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Python/" itemprop="url" rel="index">
                    <span itemprop="name">Python</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/12/28/(转载) python requests模块的使用/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/12/28/(转载) python requests模块的使用/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="（转载）python-requests模块的使用"><a href="#（转载）python-requests模块的使用" class="headerlink" title="（转载）python requests模块的使用"></a>（转载）python requests模块的使用</h1><h4 id="原文地址：http-www-cnblogs-com-tangdongchu-p-4229049-html"><a href="#原文地址：http-www-cnblogs-com-tangdongchu-p-4229049-html" class="headerlink" title="原文地址：http://www.cnblogs.com/tangdongchu/p/4229049.html"></a>原文地址：<a href="http://www.cnblogs.com/tangdongchu/p/4229049.html" target="_blank" rel="external">http://www.cnblogs.com/tangdongchu/p/4229049.html</a></h4><h3 id="1、Requests模块说明"><a href="#1、Requests模块说明" class="headerlink" title="1、Requests模块说明"></a>1、Requests模块说明</h3><p>Requests 是使用 <a href="http://cn.python-requests.org/en/latest/user/intro.html#apache2" target="_blank" rel="external">Apache2 Licensed</a> 许可证的 HTTP 库。用 Python 编写，真正的为人类着想。</p>
<p>Python 标准库中的 <strong>urllib2</strong> 模块提供了你所需要的大多数 HTTP 功能，但是它的 API 太渣了。它是为另一个时代、另一个互联网所创建的。它需要巨量的工作，甚至包括各种方法覆盖，来完成最简单的任务。</p>
<p>在Python的世界里，事情不应该这么麻烦。</p>
<p>Requests 使用的是 <strong>urllib3</strong>，因此继承了它的所有特性。Requests 支持 HTTP 连接保持和连接池，支持使用 cookie 保持会话，支持文件上传，支持自动确定响应内容的编码，支持国际化的 URL 和 POST 数据自动编码。现代、国际化、人性化。</p>
<p>（以上转自Requests官方文档）</p>
<h3 id="2、Requests模块安装"><a href="#2、Requests模块安装" class="headerlink" title="2、Requests模块安装"></a>2、Requests模块安装</h3><p><a href="http://docs.python-requests.org/en/latest/user/install/#install" target="_blank" rel="external">点此下载</a></p>
<p>然后执行安装<br> | <code>$ python setup.py install</code></p>
<p>个人推荐使用pip安装<br> | <code>pip install requests</code></p>
<p>也可以使用easy_install安装</p>
<p> | <code>easy_install requests</code></p>
<p>尝试在IDE中import requests，如果没有报错，那么安装成功。</p>
<h3 id="3、Requests模块简单入门"><a href="#3、Requests模块简单入门" class="headerlink" title="3、Requests模块简单入门"></a>3、Requests模块简单入门</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#HTTP请求类型</span></div><div class="line"><span class="comment">#get类型</span></div><div class="line">r = requests.get(<span class="string">'https://github.com/timeline.json'</span>)</div><div class="line"><span class="comment">#post类型</span></div><div class="line">r = requests.post(<span class="string">"http://m.ctrip.com/post"</span>)</div><div class="line"><span class="comment">#put类型</span></div><div class="line">r = requests.put(<span class="string">"http://m.ctrip.com/put"</span>)</div><div class="line"><span class="comment">#delete类型</span></div><div class="line">r = requests.delete(<span class="string">"http://m.ctrip.com/delete"</span>)</div><div class="line"><span class="comment">#head类型</span></div><div class="line">r = requests.head(<span class="string">"http://m.ctrip.com/head"</span>)</div><div class="line"><span class="comment">#options类型</span></div><div class="line">r = requests.options(<span class="string">"http://m.ctrip.com/get"</span>)</div><div class="line"></div><div class="line"><span class="comment">#获取响应内容</span></div><div class="line"><span class="keyword">print</span> r.content <span class="comment">#以字节的方式去显示，中文显示为字符</span></div><div class="line"><span class="keyword">print</span> r.text <span class="comment">#以文本的方式去显示</span></div><div class="line"></div><div class="line"><span class="comment">#URL传递参数</span></div><div class="line">payload = &#123;<span class="string">'keyword'</span>: <span class="string">'日本'</span>, <span class="string">'salecityid'</span>: <span class="string">'2'</span>&#125;</div><div class="line">r = requests.get(<span class="string">"http://m.ctrip.com/webapp/tourvisa/visa_list"</span>, params=payload) </div><div class="line"><span class="keyword">print</span> r.url <span class="comment">#示例为http://m.ctrip.com/webapp/tourvisa/visa_list?salecityid=2&amp;keyword=日本</span></div><div class="line"></div><div class="line"><span class="comment">#获取/修改网页编码</span></div><div class="line">r = requests.get(<span class="string">'https://github.com/timeline.json'</span>)</div><div class="line"><span class="keyword">print</span> r.encoding</div><div class="line">r.encoding = <span class="string">'utf-8'</span></div><div class="line"></div><div class="line"><span class="comment">#json处理</span></div><div class="line">r = requests.get(<span class="string">'https://github.com/timeline.json'</span>)</div><div class="line"><span class="keyword">print</span> r.json() <span class="comment">#需要先import json    </span></div><div class="line"></div><div class="line"><span class="comment">#定制请求头</span></div><div class="line">url = <span class="string">'http://m.ctrip.com'</span></div><div class="line">headers = &#123;<span class="string">'User-Agent'</span> : <span class="string">'Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 4 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19'</span>&#125;</div><div class="line">r = requests.post(url, headers=headers)</div><div class="line"><span class="keyword">print</span> r.request.headers</div><div class="line"></div><div class="line"><span class="comment">#复杂post请求</span></div><div class="line">url = <span class="string">'http://m.ctrip.com'</span></div><div class="line">payload = &#123;<span class="string">'some'</span>: <span class="string">'data'</span>&#125;</div><div class="line">r = requests.post(url, data=json.dumps(payload)) <span class="comment">#如果传递的payload是string而不是dict，需要先调用dumps方法格式化一下</span></div><div class="line"></div><div class="line"><span class="comment">#post多部分编码文件</span></div><div class="line">url = <span class="string">'http://m.ctrip.com'</span></div><div class="line">files = &#123;<span class="string">'file'</span>: open(<span class="string">'report.xls'</span>, <span class="string">'rb'</span>)&#125;</div><div class="line">r = requests.post(url, files=files)</div><div class="line"></div><div class="line"><span class="comment">#响应状态码</span></div><div class="line">r = requests.get(<span class="string">'http://m.ctrip.com'</span>)</div><div class="line"><span class="keyword">print</span> r.status_code</div><div class="line">    </div><div class="line"><span class="comment">#响应头</span></div><div class="line">r = requests.get(<span class="string">'http://m.ctrip.com'</span>)</div><div class="line"><span class="keyword">print</span> r.headers</div><div class="line"><span class="keyword">print</span> r.headers[<span class="string">'Content-Type'</span>]</div><div class="line"><span class="keyword">print</span> r.headers.get(<span class="string">'content-type'</span>) <span class="comment">#访问响应头部分内容的两种方式</span></div><div class="line">    </div><div class="line"><span class="comment">#Cookies</span></div><div class="line">url = <span class="string">'http://example.com/some/cookie/setting/url'</span></div><div class="line">r = requests.get(url)</div><div class="line">r.cookies[<span class="string">'example_cookie_name'</span>]    <span class="comment">#读取cookies</span></div><div class="line">    </div><div class="line">url = <span class="string">'http://m.ctrip.com/cookies'</span></div><div class="line">cookies = dict(cookies_are=<span class="string">'working'</span>)</div><div class="line">r = requests.get(url, cookies=cookies) <span class="comment">#发送cookies</span></div><div class="line"></div><div class="line"><span class="comment">#设置超时时间</span></div><div class="line">r = requests.get(<span class="string">'http://m.ctrip.com'</span>, timeout=<span class="number">0.001</span>)</div><div class="line"></div><div class="line"><span class="comment">#设置访问代理</span></div><div class="line">proxies = &#123;</div><div class="line">           <span class="string">"http"</span>: <span class="string">"http://10.10.10.10:8888"</span>,</div><div class="line">           <span class="string">"https"</span>: <span class="string">"http://10.10.10.100:4444"</span>,</div><div class="line">          &#125;</div><div class="line">r = requests.get(<span class="string">'http://m.ctrip.com'</span>, proxies=proxies)</div></pre></td></tr></table></figure>
<h3 id="4、Requests示例"><a href="#4、Requests示例" class="headerlink" title="4、Requests示例"></a>4、Requests示例</h3><p><strong>json请求</strong></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#!/user/bin/env python</span></div><div class="line"><span class="comment">#coding=utf-8</span></div><div class="line"><span class="keyword">import</span> requests</div><div class="line"><span class="keyword">import</span> json</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">url_request</span><span class="params">()</span>:</span></div><div class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self)</span>:</span></div><div class="line">            <span class="string">""" init """</span>    </div><div class="line"></div><div class="line"><span class="keyword">if</span> __name__==<span class="string">'__main__'</span>:</div><div class="line">    headers = &#123;<span class="string">'Content-Type'</span> : <span class="string">'application/json'</span>&#125;</div><div class="line">    payload = &#123;<span class="string">'CountryName'</span>:<span class="string">'中国'</span>,</div><div class="line">               <span class="string">'ProvinceName'</span>:<span class="string">'陕西省'</span>,</div><div class="line">               <span class="string">'L1CityName'</span>:<span class="string">'汉中'</span>,</div><div class="line">               <span class="string">'L2CityName'</span>:<span class="string">'城固'</span>,</div><div class="line">               <span class="string">'TownName'</span>:<span class="string">''</span>,</div><div class="line">               <span class="string">'Longitude'</span>:<span class="string">'107.33393'</span>,</div><div class="line">               <span class="string">'Latitude'</span>:<span class="string">'33.157131'</span>,</div><div class="line">               <span class="string">'Language'</span>:<span class="string">'CN'</span></div><div class="line">               &#125;</div><div class="line">    r = requests.post(<span class="string">"http://www.xxxxxx.com/CityLocation/json/LBSLocateCity"</span>,headers=headers,data=payload)</div><div class="line">    <span class="comment">#r.encoding = 'utf-8'</span></div><div class="line">    data=r.json()</div><div class="line">    <span class="keyword">if</span> r.status_code!=<span class="number">200</span>:</div><div class="line">        <span class="keyword">print</span> <span class="string">"LBSLocateCity API Error "</span> + str(r.status_code)</div><div class="line">    <span class="keyword">print</span> data[<span class="string">'CityEntities'</span>][<span class="number">0</span>][<span class="string">'CityID'</span>] <span class="comment">#打印返回json中的某个key的value</span></div><div class="line">    <span class="keyword">print</span> data[<span class="string">'ResponseStatus'</span>][<span class="string">'Ack'</span>]</div><div class="line">    <span class="keyword">print</span> json.dumps(data,indent=<span class="number">4</span>,sort_keys=<span class="keyword">True</span>,ensure_ascii=<span class="keyword">False</span>) <span class="comment">#树形打印json，ensure_ascii必须设为False否则中文会显示为unicode</span></div></pre></td></tr></table></figure>
<p><strong>xml请求</strong></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#!/user/bin/env python</span></div><div class="line"><span class="comment">#coding=utf-8</span></div><div class="line"><span class="keyword">import</span> requests</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">url_request</span><span class="params">()</span>:</span></div><div class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self)</span>:</span></div><div class="line">            <span class="string">""" init """</span>    </div><div class="line"></div><div class="line"><span class="keyword">if</span> __name__==<span class="string">'__main__'</span>:</div><div class="line">    </div><div class="line">    headers = &#123;<span class="string">'Content-type'</span>: <span class="string">'text/xml'</span>&#125;</div><div class="line">    XML = <span class="string">'&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soap:Body&gt;&lt;Request xmlns="http://tempuri.org/"&gt;&lt;jme&gt;&lt;JobClassFullName&gt;WeChatJSTicket.JobWS.Job.JobRefreshTicket,WeChatJSTicket.JobWS&lt;/JobClassFullName&gt;&lt;Action&gt;RUN&lt;/Action&gt;&lt;Param&gt;1&lt;/Param&gt;&lt;HostIP&gt;127.0.0.1&lt;/HostIP&gt;&lt;JobInfo&gt;1&lt;/JobInfo&gt;&lt;NeedParallel&gt;false&lt;/NeedParallel&gt;&lt;/jme&gt;&lt;/Request&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;'</span></div><div class="line">    url = <span class="string">'http://jobws.push.mobile.xxxxxxxx.com/RefreshWeiXInTokenJob/RefreshService.asmx'</span></div><div class="line">    r = requests.post(url,headers=headers,data=XML)</div><div class="line">    <span class="comment">#r.encoding = 'utf-8'</span></div><div class="line">    data = r.text</div><div class="line">    <span class="keyword">print</span> data</div></pre></td></tr></table></figure>
<h3 id="5、参考文档"><a href="#5、参考文档" class="headerlink" title="5、参考文档"></a>5、参考文档</h3><p><a href="http://cn.python-requests.org/en/latest/" target="_blank" rel="external">http://cn.python-requests.org/en/latest/</a></p>
<p><a href="http://docs.python-requests.org/en/latest/user/quickstart.html" target="_blank" rel="external">http://docs.python-requests.org/en/latest/user/quickstart.html</a></p>

      
    </div>

    <div>
      
        
      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="/path/to/wechat-reward-image" alt="Rainy008 WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="/path/to/alipay-reward-image" alt="Rainy008 Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/模块使用/" rel="tag">#模块使用</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/09/21/字符编码/" rel="next" title="字符编码 （Python3 基础教程(廖雪峰) P47）">
                <i class="fa fa-chevron-left"></i> 字符编码 （Python3 基础教程(廖雪峰) P47）
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/05/31/splite 避免插入重复数据/" rel="prev" title="splite避免插入重复数据">
                splite避免插入重复数据 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2016/12/28/(转载) python requests模块的使用/"
           data-title="python requests模块的使用" data-url="http://rainy008.github.io/2016/12/28/(转载) python requests模块的使用/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.gif"
               alt="Rainy008" />
          <p class="site-author-name" itemprop="name">Rainy008</p>
          <p class="site-description motion-element" itemprop="description">留下记忆足迹，记录所学所想</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">8</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">4</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">5</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#（转载）python-requests模块的使用"><span class="nav-text">（转载）python requests模块的使用</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#原文地址：http-www-cnblogs-com-tangdongchu-p-4229049-html"><span class="nav-text">原文地址：http://www.cnblogs.com/tangdongchu/p/4229049.html</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1、Requests模块说明"><span class="nav-text">1、Requests模块说明</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2、Requests模块安装"><span class="nav-text">2、Requests模块安装</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3、Requests模块简单入门"><span class="nav-text">3、Requests模块简单入门</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4、Requests示例"><span class="nav-text">4、Requests示例</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5、参考文档"><span class="nav-text">5、参考文档</span></a></li></ol></li></ol></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Rainy008</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="http://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"rainy008"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
  





  
  
  

  

  

</body>
</html>
